home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-12-05 | 1.2 KB | 57 lines | [TEXT/ttxt] |
- // EqualTangents
- // set all selected points of an Hermite Spline to the
- // same length, defined by the user
- // (c) Christian Losch
- // 1997 Maxon Computer GmbH
-
- var len_vl,len_vr;
-
- Function(doc)
- {
- var i,num,op,info,dlg,sp;
-
- // allocate all data
- info = new (SplineInfo); if (!info) return;
- sp = new (SplinePoint); if (!sp) return;
- dlg = new (SimpleDialog); if (!dlg) return;
-
- // get active object
- op = doc->FindFirstActiveObject(); if (!op || getclass(op)!=SplineObject) return;
- op->GetSplineInfo(info);
- if (info->type!=SPL_HERMITE)
- {
- TextDialog("No Hermite Spline");
- return;
- }
-
- // user dialog
- dlg->SetTitle("EqualTangents");
- dlg->SetData(0,"Left" ,FIELD_FLOAT,0.0,1E6,len_vl);
- dlg->SetData(1,"Right",FIELD_FLOAT,0.0,1E6,len_vr);
- if (!dlg->DoDialog()) return;
-
- len_vl = dlg->GetData(0);
- len_vr = dlg->GetData(1);
-
- // change tangents
- num = op->GetPointNumber();
- for (i=0; i<num; i++)
- {
- if (op->IsPointSelected(i) && op->GetPoint(i,sp))
- {
- sp->vl = vnorm(sp->vl)*len_vl;
- sp->vr = vnorm(sp->vr)*len_vr;
- op->SetPoint(i,sp);
- }
- }
-
- op->UpdateObject();
- doc->SendMessage(ACTIVE_OBJECT_CHANGED);
- }
-
-
- main()
- {
- len_vl = len_vr = 50.0;
- RegisterMenuHook("Equal Tangents","Function");
- }